﻿using System;
using System.IO;
using HAVNet.Core.Lambda;


namespace HAVNet.Core.IO
{
    public delegate void FileTraverserLineFunc (string line);

    public class Files
    {
        public static void traverseAllLines (StreamReader sr,  FileTraverserLineFunc f )
        {
            string linea = string.Empty;

            while (null != (linea = sr.ReadLine()))
                f (linea);
        }

        public static void traverseAllLines (string path, FileTraverserLineFunc f)
        {
            using (StreamReader sr = File.OpenText(path))
            {
                traverseAllLines    (sr, f);
                sr.Close            ();
            }
        }
    }
}
